package com.putable.nmc.dmv;

import com.putable.pqueue.AbstractPQAble;
import com.putable.pqueue.PQueue;

/**
 * 
 * @author Todd
 *
 * Abstract class that could refer to anything being put into the PQueue for this simulation
 * Most notably contains the compareTo method
 */
public abstract class PQElement extends  AbstractPQAble {
	public PQElement(){
		
	}
	public PQElement(PQueue pq){
		setPQueue(pq);
	}
	
	private double timeOfNextTask;
	
	public double getTimeOfNextTask() {
		return timeOfNextTask;
	}
	
	public void setTimeOfNextTask(double time) {
		this.timeOfNextTask = time;
	}

	
	@Override
	public int compareTo(Object o) {
		PQElement pqa;
		if(o instanceof PQElement){
			pqa = (PQElement) o;
			//Compares this index to the given one
			return (int)(pqa.getTimeOfNextTask()-this.getTimeOfNextTask());
		}
		throw new ClassCastException();
	}
	
	
	/**
	 * @param initState The initial state of the element
	 * @param curState The current state of the element
	 */
	private State  curState;
	
	/**
	 * Run through the various tasks specific to each element
	 * @param time TODO
	 * @param cLine TODO
	 */
	public abstract void run(double time, CustomerLine cLine);
	

	/**
	 * Gets the current state of the element
	 * @return The current state
	 */
	public State getState() {
		return curState;
	}
	/**
	 * Sets the current state of the element
	 * @param curState The new current state
	 */
	public void setState(State curState) {
		this.curState = curState;
	}
	
	
}
